package com.ciwong.epaper.modules.me.ui;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.me.util.MeJumpManager;
import com.ciwong.epaper.util.IntentFlag;
import com.ciwong.mobilelib.i.ViewOnClickListener;
import com.ciwong.mobilelib.ui.BaseActivity;

/**
 * 修改绑定手机
 * Created by young on 2016/6/15.
 */
public class ModifyMyPhoneActivity extends BaseActivity{
    private ViewGroup modify_container;
    private ViewGroup modify_phone_linearconner;
    private TextView tv_your_bind_phone;
    private Button modify_your_phone_btn;
    private ImageView upe_phone_number_go_back;
    private String phonenumber;
    private String err_tips_errphone;
    private final int TIPS_GONE=1;




    private View.OnClickListener mOnClickLitener=new ViewOnClickListener() {
        @Override
        public void avertRepeatOnClick(View v) {
            int id=v.getId();
            if(id==R.id.modify_your_phone_btn){
                if(!phonenumber.isEmpty()){
                    modifyPhone(phonenumber);
                   /* err_tips_errphone=getString(R.string.err_tips_errphone);
                    errTips(err_tips_tv,err_tips_errphone);*/
                }
            }
        }
    };
    @Override
    protected int setView() {
        return R.layout.activity_modify_phone;
    }

    @Override
    protected void findViews() {
        modify_container=(ViewGroup)findViewById(R.id.modify_container);
        modify_phone_linearconner=(ViewGroup)findViewById(R.id.modify_phone_linearconner);
        tv_your_bind_phone=(TextView) findViewById(R.id.tv_your_bind_phone);
        modify_your_phone_btn=(Button) findViewById(R.id.modify_your_phone_btn);
        upe_phone_number_go_back = (ImageView) findViewById(R.id.upe_phone_number_go_back);
    }

    @Override
    protected void initEvent() {
        modify_your_phone_btn.setOnClickListener(mOnClickLitener);
        upe_phone_number_go_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    protected void init() {
        setValideSource(true);
        hideTitleBar();
        //setTitleText(getResources().getString(R.string.binded_phone));
        /*setGoBackListener(new GoBackListener() {
            @Override
            public void goBack() {
            finish();
            }
        });*/
    }

    @Override
    protected void loadData() {
        Intent intent=getIntent();
        if(intent!=null){
            phonenumber=intent.getStringExtra(IntentFlag.INTENT_FLAG_STR);
        }
        if(!phonenumber.isEmpty()){
            tv_your_bind_phone.setText(getResources().getString(R.string.your_phone_number)+phonenumber);
        }


    }






    /**
     * 更换手机号
     * @param phonenumber
     */

    private void modifyPhone(String phonenumber){
        //跳转绑定手机号页面  4代表来自换绑页面
        MeJumpManager.jumpToBindPhoneActivity(R.string.go_back,ModifyMyPhoneActivity.this,"","4");
        ModifyMyPhoneActivity.this.finish();
    }


}
